﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business.Base
{
    public class ExperimentRule
    {
        private static List<ExperimentRule> experimentRuleList = new List<ExperimentRule>();
        public static List<ExperimentRule> ExperimentRuleList { get => experimentRuleList; }
        public static string experimentTable = "experiment";
        public static Dictionary<string, string> experimentDBMap = new Dictionary<string, string>();



        /// <summary>
        /// 初始化试验规则
        /// </summary>
        static ExperimentRule()
        {
           
            #region  基础表数据库字段映射

            experimentDBMap.Add("code", "Code");
            experimentDBMap.Add("createTime", "CreateTime");
            experimentDBMap.Add("pumpModel", "PumpModel");
            experimentDBMap.Add("pumpCode", "PumpCode");
            experimentDBMap.Add("experimentOwner", "ExperimentOwner");
            experimentDBMap.Add("manufacturer", "Manufacturer");
            experimentDBMap.Add("pumpType", "PumpType");
            experimentDBMap.Add("experimentType", "ExperimentType");
            experimentDBMap.Add("filePath", "FilePath");
            experimentDBMap.Add("customer", "Customer");
            experimentDBMap.Add("pumpName", "PumpName");
        
            #endregion


            Dictionary<string, string> centrifugalPumpDBMap = new Dictionary<string, string>();
            #region  离心泵的数据库字典


            centrifugalPumpDBMap.Add("experimentCode","Code");
            centrifugalPumpDBMap.Add("designFlow","DesignFlow");
            centrifugalPumpDBMap.Add("designHead","DesignHead");
            centrifugalPumpDBMap.Add("designShaftPower","DesignShaftPower");
            centrifugalPumpDBMap.Add("designPumpEfficiency","DesignPumpEfficiency");
            centrifugalPumpDBMap.Add("designNPSH","DesignNPSH");
            centrifugalPumpDBMap.Add("designStages","DesignStages");
            centrifugalPumpDBMap.Add("designRatedSpeed","DesignRatedSpeed");
            centrifugalPumpDBMap.Add("designSynchronousSpeed","DesignSynchronousSpeed");
            centrifugalPumpDBMap.Add("designRatedVoltage","DesignRatedVoltage");
            centrifugalPumpDBMap.Add("designRatedCurrent","DesignRatedCurrent");
            centrifugalPumpDBMap.Add("designWindingConnection","DesignWindingConnection");
            centrifugalPumpDBMap.Add("designWindingMaterial","DesignWindingMaterial");

            centrifugalPumpDBMap.Add("currentTransformationRatio","CurrentTransformationRatio");
            centrifugalPumpDBMap.Add("motorEfficiency","MotorEfficiency");

            centrifugalPumpDBMap.Add("dInlet","DInlet");
            centrifugalPumpDBMap.Add("dOutlet","DOutlet");
            centrifugalPumpDBMap.Add("zInlet","ZInlet");
            centrifugalPumpDBMap.Add("zOutlet","ZOutlet");
            centrifugalPumpDBMap.Add("lInlet","LInlet");
            centrifugalPumpDBMap.Add("lOutlet","LOutlet");

            centrifugalPumpDBMap.Add("kInlet","KInlet");
            centrifugalPumpDBMap.Add("kOutlet","KOutlet");
            centrifugalPumpDBMap.Add("flowmeter","Flowmeter");
            centrifugalPumpDBMap.Add("flowmeterAddress","FlowmeterAddress");

            centrifugalPumpDBMap.Add("experimentResultFlow","ExperimentResultFlow");
            centrifugalPumpDBMap.Add("experimentResultHead","ExperimentResultHead");
            centrifugalPumpDBMap.Add("experimentResultPower","ExperimentResultPower");

            centrifugalPumpDBMap.Add("experimentResultEff","ExperimentResultEff");
            centrifugalPumpDBMap.Add("experimentResultFlowIsPass","ExperimentResultFlowIsPass");
            centrifugalPumpDBMap.Add("experimentResultHeadIsPass","ExperimentResultHeadIsPass");
            centrifugalPumpDBMap.Add("experimentResultPowerIsPass","ExperimentResultPowerIsPass");
            centrifugalPumpDBMap.Add("experimentResultEffIsPass","ExperimentResultEffIsPass");
            #endregion

            Dictionary<string, string> screwPumpDBMap = new Dictionary<string, string>();
            #region 螺杆泵数据库字典
            screwPumpDBMap.Add("experimentCode","Code");
            screwPumpDBMap.Add("designFlow", "DesignFlow");
            screwPumpDBMap.Add("designPresure", "DesignPressure");
            screwPumpDBMap.Add("designShaftPower", "DesignShaftPower");
            screwPumpDBMap.Add("designPumpEfficiency", "DesignPumpEfficiency");
            screwPumpDBMap.Add("designNPSH", "DesignNPSH");

            screwPumpDBMap.Add("designStages", "DesignStages");
            screwPumpDBMap.Add("designRatedSpeed", "DesignRatedSpeed");
            screwPumpDBMap.Add("designSynchronousSpeed", "DesignSynchronousSpeed");
            screwPumpDBMap.Add("designRatedVoltage", "DesignRatedVoltage");
            screwPumpDBMap.Add("designRatedCurrent", "DesignRatedCurrent");
            screwPumpDBMap.Add("designWindingConnection", "DesignWindingConnection");
            screwPumpDBMap.Add("designWindingMaterial", "DesignWindingMaterial");
            screwPumpDBMap.Add("currentTransformationRatio", "CurrentTransformationRatio");
            screwPumpDBMap.Add("motorEfficiency", "MotorEfficiency");

            screwPumpDBMap.Add("dInlet", "DInlet");
            screwPumpDBMap.Add("dOutlet", "DOutlet");
            screwPumpDBMap.Add("zInlet", "ZInlet");
            screwPumpDBMap.Add("zOutlet", "ZOutlet");
            screwPumpDBMap.Add("lInlet", "LInlet");
            screwPumpDBMap.Add("lOutlet", "LOutlet");

            screwPumpDBMap.Add("kInlet", "KInlet");
            screwPumpDBMap.Add("kOutlet", "KOutlet");
            screwPumpDBMap.Add("flowmeter", "Flowmeter");
            screwPumpDBMap.Add("flowmeterAddress", "FlowmeterAddress");

            screwPumpDBMap.Add("experimentResultFlow", "ExperimentResultFlow");
            screwPumpDBMap.Add("experimentResultPresure", "ExperimentResultPressure");
            screwPumpDBMap.Add("experimentResultPower", "ExperimentResultPower");

            screwPumpDBMap.Add("experimentResultEff", "ExperimentResultEff");
            screwPumpDBMap.Add("experimentResultFlowIsPass", "ExperimentResultFlowIsPass");
            screwPumpDBMap.Add("experimentResultPresureIsPass", "ExperimentResultPressureIsPass");
            screwPumpDBMap.Add("experimentResultPowerIsPass", "ExperimentResultPowerIsPass");
            screwPumpDBMap.Add("experimentResultEffIsPass", "ExperimentResultEffIsPass");
            #endregion

            Dictionary<string, string> centrifugalPumpDBRecordMap = new Dictionary<string, string>();
            #region 离心泵试验数据字典

            centrifugalPumpDBRecordMap.Add("experimentCode","ExperimentCode");
            centrifugalPumpDBRecordMap.Add("recordTime", "RecordTime");
            //centrifugalPumpDBRecordMap.Add("experiment", "Experiment");
            centrifugalPumpDBRecordMap.Add("workFlow", "WorkFlow");
            centrifugalPumpDBRecordMap.Add("presureIn", "PresureIn");
            centrifugalPumpDBRecordMap.Add("presureOut", "PresureOut");
            centrifugalPumpDBRecordMap.Add("electricCurrent", "ElectricCurrent");
            centrifugalPumpDBRecordMap.Add("voltage", "Voltage");
            centrifugalPumpDBRecordMap.Add("workingPower", "WorkingPower");
            centrifugalPumpDBRecordMap.Add("workingSpeed", "WorkingSpeed");
            centrifugalPumpDBRecordMap.Add("temperature", "Temperature");
            centrifugalPumpDBRecordMap.Add("workingHead", "WorkingHead");
            centrifugalPumpDBRecordMap.Add("stpFlow", "StpFlow");
            centrifugalPumpDBRecordMap.Add("stpHead", "StpHead");
            centrifugalPumpDBRecordMap.Add("stpShaftPower", "StpShaftPower");
            centrifugalPumpDBRecordMap.Add("stpPumpEfficiency", "StpPumpEfficiency");
            centrifugalPumpDBRecordMap.Add("stpGroupEfficiency", "StpGroupEfficiency");
            centrifugalPumpDBRecordMap.Add("workingStaticHead", "WorkingStaticHead");
            centrifugalPumpDBRecordMap.Add("workingDynamicHead", "WorkingDynamicHead");
            centrifugalPumpDBRecordMap.Add("workingGeoHead", "WorkingGeoHead");
            centrifugalPumpDBRecordMap.Add("workingFrictionHead", "WorkingFrictionHead");
            #endregion

            Dictionary<string, string> screwPumpDBRecordMap = new Dictionary<string, string>();
            #region 螺杆泵试验数据字典
            screwPumpDBRecordMap.Add("experimentCode", "ExperimentCode");
            screwPumpDBRecordMap.Add("recordTime", "RecordTime");
            //screwPumpDBRecordMap.Add("experiment", perfExperimentRecord.Experiment");
            screwPumpDBRecordMap.Add("workFlow", "WorkFlow");
            screwPumpDBRecordMap.Add("presureIn", "PresureIn");
            screwPumpDBRecordMap.Add("presureOut", "PresureOut");
            screwPumpDBRecordMap.Add("presureTotal", "PresureTotal");
            screwPumpDBRecordMap.Add("electricCurrent", "ElectricCurrent");
            screwPumpDBRecordMap.Add("voltage", "Voltage");
            screwPumpDBRecordMap.Add("workingPower", "WorkingPower");
            screwPumpDBRecordMap.Add("workingSpeed", "WorkingSpeed");
            screwPumpDBRecordMap.Add("temperature", "Temperature");
            screwPumpDBRecordMap.Add("workingHead", "WorkingHead");
            screwPumpDBRecordMap.Add("stpFlow", "StpFlow");
            screwPumpDBRecordMap.Add("stpHead", "StpHead");
            screwPumpDBRecordMap.Add("stpPresure", "StpPresure");
            screwPumpDBRecordMap.Add("stpShaftPower", "StpShaftPower");
            screwPumpDBRecordMap.Add("stpPumpEfficiency", "StpPumpEfficiency");
            screwPumpDBRecordMap.Add("stpGroupEfficiency", "StpGroupEfficiency");
            screwPumpDBRecordMap.Add("workingStaticHead", "WorkingStaticHead");
            screwPumpDBRecordMap.Add("workingDynamicHead", "WorkingDynamicHead");
            screwPumpDBRecordMap.Add("workingGeoHead", "WorkingGeoHead");
            screwPumpDBRecordMap.Add("workingFrictionHead", "WorkingFrictionHead");

            #endregion

            Dictionary<string, string> npshDBRecordMap = new Dictionary<string, string>();
            #region 汽蚀试验的数据字典
            npshDBRecordMap.Add("experimentCode", "ExperimentCode");
            npshDBRecordMap.Add("recordTime", "RecordTime");
            npshDBRecordMap.Add("presureIn", "PresureIn");
            npshDBRecordMap.Add("presureOut", "PresureOut");
            npshDBRecordMap.Add("workingPower", "WorkingPower");
            npshDBRecordMap.Add("temperature", "Temperature");
            npshDBRecordMap.Add("head", "Head");
            npshDBRecordMap.Add("npsh", "Npsh");
            #endregion

   



                   


            //离心泵性能测试规则字典
            ExperimentRule centrifugalPumpPerfDBRule = new ExperimentRule(PumpType.CentrifugalPump, ExperimentType.Perf, "perfExperiment", "perfExperimentRecord", centrifugalPumpDBMap, centrifugalPumpDBRecordMap);
            //螺杆泵性能测试规则字典
            ExperimentRule screwPumpPerfDBRule = new ExperimentRule(PumpType.ScrewPump,ExperimentType.Perf, "ScrewPump_Perf_Experiment", "ScrewPump_Perf_ExperimentRecord", screwPumpDBMap, screwPumpDBRecordMap);

            ExperimentRule npshDBRule = new ExperimentRule(ExperimentType.Npsh, "npshExperimentRecord", npshDBRecordMap);

           

            experimentRuleList.Add(centrifugalPumpPerfDBRule);
            experimentRuleList.Add(screwPumpPerfDBRule);
            experimentRuleList.Add(npshDBRule);
           


        }

        PumpType pumpType;
        ExperimentType experimentType;

        String attachInfoTable;
        String recordTable;
        Dictionary<string, string> dbFieldMap;//数据库字段与对象的映射关系 
        Dictionary<string, string> dbRecordFieldMap;
        private ExperimentType npsh;
        private string v;
        private Dictionary<string, string> npshDBRecordMap;

        public ExperimentRule(PumpType pumpType, ExperimentType experimentType,  string attachInfoTable, string recordTable, Dictionary<string, string> dbFieldMap,Dictionary<string,string> dbRecordFieldMap)
        {
            this.pumpType = pumpType;
            this.experimentType = experimentType;
            this.recordTable = recordTable;
            this.attachInfoTable = attachInfoTable;
            this.dbFieldMap = dbFieldMap;
            this.dbRecordFieldMap = dbRecordFieldMap;
        }

        public ExperimentRule(ExperimentType experimentType, string recordTable, Dictionary<string, string> npshDBRecordMap)
        {
            this.pumpType = PumpType.Any;
            this.attachInfoTable = null;
            this.dbFieldMap = null;
            this.experimentType = experimentType;
            this.recordTable = recordTable;
            this.dbRecordFieldMap = npshDBRecordMap;
        }

        public ExperimentRule(string recordTable,Dictionary<string, string> npshDBRecordMap)
        {
            this.pumpType = PumpType.None;
            this.attachInfoTable = null;
            this.dbFieldMap = null;
            this.experimentType = ExperimentType.None;
            this.recordTable = recordTable;
            this.dbRecordFieldMap = npshDBRecordMap;
        }

        public PumpType PumpType { get => pumpType; set => pumpType = value; }
        public ExperimentType ExperimentType { get => experimentType; set => experimentType = value; }
        public string AttachInfoTable { get => attachInfoTable; set => attachInfoTable = value; }
        public string RecordTable { get => recordTable; set => recordTable = value; }
        public Dictionary<string, string> DbFiledMap { get => dbFieldMap; set => dbFieldMap = value; }
        public Dictionary<string, string> DbRecordFieldMap { get => dbRecordFieldMap; set => dbRecordFieldMap = value; }
    }
}
